using System;
using System.Diagnostics;

namespace Seagull.Model.Stat
{
    [DebuggerDisplay("{ToString()}")]
    public struct TimeStatistic : IEquatable<TimeStatistic>
    {
        public DateTime Time;

        public Statistic Statistic;

        public TimeStatistic(DateTime time, Statistic statistic)
        {
            Time = time;
            Statistic = statistic;
        }

        #region Equality Members

        public bool Equals(TimeStatistic other)
        {
            return other.Time.Equals(Time) && other.Statistic.Equals(Statistic);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (obj.GetType() != typeof (TimeStatistic)) return false;
            return Equals((TimeStatistic) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (Time.GetHashCode()*397) ^ Statistic.GetHashCode();
            }
        }

        public static bool operator ==(TimeStatistic left, TimeStatistic right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(TimeStatistic left, TimeStatistic right)
        {
            return !left.Equals(right);
        }

        #endregion

        public override string ToString()
        {
            return string.Format("Time: {0}, Statistic: {1}", Time, Statistic);
        }
    }
}